{
  "properties" : { },
  "id" : "3eb74c1aabff4b9c8757a4853c8997d8",
  "script" : null,
  "groupId" : "ded0996d4aa14841ae2d40edb1fa6d63",
  "name" : "查询调度机构树形结构",
  "createTime" : 1727071135750,
  "updateTime" : 1726728553469,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "queryDeptTree",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": [\n        {\n            \"id\": \"1793494418083319810\",\n            \"parentId\": 0,\n            \"weight\": 0,\n            \"name\": \"陕西省调\",\n            \"children\": [\n                {\n                    \"id\": \"1803254752905129985\",\n                    \"parentId\": \"1793494418083319810\",\n                    \"weight\": 0,\n                    \"name\": \"延安\"\n                }\n            ]\n        }\n    ]\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "status",
      "value" : "500",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "系统内部出现错误",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
import cn.hutool.core.collection.CollUtil
import java.lang.reflect.Array
import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.lang.tree.TreeUtil
import cn.hutool.core.lang.tree.TreeNode
import java.math.BigDecimal

var sql = """
    SELECT id, parent_Id, dept_Name group_name
    FROM blade_dept
    WHERE is_Deleted =0
"""
var list = db.select(sql)
// 构建node列表
List nodeList = CollUtil.newArrayList();
list.map(r -> {
    // nodeList.add(new TreeNode(r.id, r.parentId,r.groupName,0) )
    nodeList.add(new TreeNode(r.id.longValue(), r.parentId.longValue(), r.groupName, 0))
})
// List treeList = TreeUtil.build(nodeList, new BigDecimal("0"));
List treeList = TreeUtil.build(nodeList, 0L); // 注意这里传入的是Long类型的0
return treeList;